<?php
use Yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
$this->title = '运营管理';
?>
<link href="/static/css/public-same.css" rel="stylesheet">
<link href="/static/css/question.css" rel="stylesheet">
 <div class="container">
    <div class="row">
       <?php echo $this->render('_leftnav'); ?>
      
        <div class="col-md-10">
          <div class="page-header clearfix">
            <h1 class="pull-left">资讯管理</h1>
          </div>
<?php $form = ActiveForm::begin(['options' => [ 'enctype' => 'multipart/form-data','class'=>'form-horizontal' ],'action' => ['operate/doart'],'method'=>'post',]); ?>
  <div class="row">
    <div class="col-md-8">
      <div class="form-group">
          <label for="article-title-field" class="control-label">资讯标题</label>
          <div class="controls">
          <input type="hidden" name="article_id" value="<?= Html::encode($date['article_id'])?>">
            <input class="form-control" id="article-title-field" type="text" name="article_title" value="<?= Html::encode($date['article_title'])?>">
          </div>
      </div>
      
      <div class="form-group">
          <label for="categoryId" class="control-label">资讯摘要</label>
          <div class="controls">
            <input class="form-control" id="categoryId" type="text" value="<?= Html::encode($date['article_descripte'])?>" name="article_descripte" tabindex="2">
              
          </div>
      </div>

      <div class="form-group">
        <label for="inpTags"　class="col-sm-1 control-label">TAG标签</label>
        <div class="controls">
        
            <div class="add-tag" style=" border: 1px solid #ccc; border-radius: 2px; overflow: hidden;">
                  <div class="hot-tag-box">
            <?php 
    				  $new_label_list = '';
    				  for($i = 0,$u=1;$i<count($label_list);$i++,$u++){
    						for($j = 0;$j<$u;$j++){
    							$new_label_list .= $label_list[$j].',';
    						}
    						$newarr[$i] = $new_label_list; // 1,    1,2,   1,2,3,
    						$new_label_list = '';
    				  }
    				  
    				  foreach ($labels as $key => $val) {?>
                     <span class="hot-tag-igroup">
                     <span class="hot-tag"><?= Html::encode($val['artlable_name'])?></span>
                     <span class="hot-tag-del">x</span>
                     <input class="tag-name-id" name="label_id" value="<?= Html::encode(rtrim($newarr[$key],','))?>" type="hidden">
                     </span>
                     
                  <?php }?>                      
                  </div>
            <input type="text" id="inpTags" m='<?php 
                        $arr = "";
                        foreach ($info as $key => $label) {
                            $name = $label['artlable_name'];
                            $label_id = $label['artlable_id'];
                            $arr[$name]=$label_id; 
                        }
                        echo json_encode($arr)?>' placeholder="直接输入可过滤标签，最多打上3个标签"   class="form-control" autocomplete="off">
            </div>
        </div>   
      </div>

      <div class="form-group">
        <label for="richeditor-body-field" class="control-label">正文</label>
        <div class="controls">
          <textarea class="form-control" id="richeditor-body-field" rows="16" name="article_contents"
            
           ><?= Html::encode($date['article_contents'])?></textarea>
        </div>
      </div>
    
    </div>
    <div class="col-md-4">
      <div class="panel panel-default">
        

      <div class="panel panel-default">
        <div class="panel-heading">作者</div>
        <div class="panel-body">
            <div class="form-group">
              <label for="article-source-field">作者名字</label>
              <div class="controls">
                <input class="form-control" id="article-source-field" type="text" name="article_author" value="<?= Html::encode($date['article_author'])?>">
              </div>
            </div>

            
        </div>
      </div>

      <div class="panel panel-default">
        <div class="panel-heading">设置封面</div>
        <div class="panel-body">
          <div id="article-thumb-container">
                          </div>
            <br>
          <span>
          <?php 
            if($date['article_thumb']){
              echo "<img src='".$date['article_thumb']."' alt='资讯图片' width='40px' height='50px'>";
            }else{
              echo "图片不存在、请上传";
            }
          ?>
          </span>
          <?= $form->field($model, 'article_thumb')->fileInput() ?>

          <p class="help-block">请上传png, gif, jpg格式的图片文件。</p>
        </div>
      </div>

      
  </div>
    <div class="form-group">
        <?= Html::submitButton('添加', ['class' => 'btn btn-primary']) ?>
    </div>           
<?php ActiveForm::end(); ?>
        </div>

          </div>
  </div>
        </div>
</div>
  
</div>
<?= Html::jsFile('/assets/ckeditor/ckeditor.js')?>
<script>CKEDITOR.replace('article_contents')</script>
<script>
  $("#lable").click(function(){
     $(".help-block").css('display','block');
  })
  /*获取标签*/

var input_tags=[];

var prefetched_tags =$.parseJSON($("#inpTags").attr("m"));      
</script>
<script type="text/javascript" src="/static/js/release.js"></script>
  
  

